﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="解碼偏移資料軟體.aspx.cs" Inherits="JsAndSilverLight.Web.解碼偏移資料軟體" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <%
        //Point[X=120.944114491886, Y=31.9499719374291, WKID=4326]
        //Point[X=122.043674793393, Y=30.6968162861439, WKID=4326]
        
        //最小點
        System.Drawing.Point minPoint = new System.Drawing.Point(12094, 3194);

        //最大點
        System.Drawing.Point MaxPoint = new System.Drawing.Point(12204, 3069);

        
        new System.Threading.Thread(new System.Threading.ThreadStart(delegate
        {
            //输出文件   
            System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("./coordSh.txt"), System.IO.FileMode.OpenOrCreate);
            System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
            //输入文件，即下载后解压后的文件   
            System.IO.FileStream fs1 = new System.IO.FileStream(Server.MapPath("./offset.xMap"), System.IO.FileMode.OpenOrCreate);
            System.IO.BinaryReader sr = new System.IO.BinaryReader(fs1);
            long records = fs1.Length / 8;
            while (records-- > 0)
            {
            
                   
                
                short longitude = sr.ReadInt16();
                short lat = sr.ReadInt16();
                short x = sr.ReadInt16();
                short y = sr.ReadInt16();
                //原來的版本
                //sw.WriteLine(longitude + "," + lat + "," + x + "," + y);
                if (longitude >= minPoint.X && longitude <= MaxPoint.X)
                {
                    if (lat <= minPoint.Y && lat >= MaxPoint.Y)
                    {
                        sw.WriteLine("shaHaiCoordTransform.Add(new SkybotCoord { Longitude=" + longitude.ToString().Insert(3, ".") + ",Lat=" + lat.ToString().Insert(2, ".") + ",X=" + x + ",Y=" + y + "});");
                    }
                }
            }


            sw.Close();
            fs.Close();
            sr.Close();
            fs1.Close();


        })).Start();
         %>
    
    </div>
    </form>
</body>
</html>
